package chapter9.demo;

import java.io.PrintStream;
import java.util.Arrays;

/**
 * @Author juzipi
 * @Date 2021/6/21 15:06
 * @Info
 */
public class ValueTransferTest {
    public static void main(String[] args) {
        //方法的形参的传递机制:值传递
        /*
        形参：方法定义时，声明在小括号内的
        实参：方法调用时，实际传递给形参的数据
         */
        int m = 20;
        int n = 10;
        System.out.println(m+" , "+n);
        ValueTransferTest valueTransferTest = new ValueTransferTest();
        //并没有交换值，因为真实存储的数据值不是同一个了
        swap(m,n);
        System.out.println();
        System.out.println("m"+m);
        System.out.println("n"+n);

        //每个位置上的值除以首位元素的值
        int[] ints = {12, 15, 456, 16, 5165, 1, 651, 65, 1, 651, 65, 165, 1, 654, 654, 65, 75};
        //注意要倒叙遍历
        for (int i = ints.length-1; i >= 0; i--) {
            ints[i] = ints[i]/ints[0];
        }
        System.out.println(Arrays.toString(ints));

        int[] ints1 = new int[10];
        System.out.println(ints1);
        char[] chars = new char[10];
        System.out.println(chars);


    }



    public static void swap(int m,int n){
        PrintStream printStream = new PrintStream(System.out){
            @Override
            public void println(String x) {
                if ("m20".equals(x)){
                    x = "m100";
                }else if ("n10".equals(x)){
                    x = "n200";
                }
                super.println(x);
            }
        };
        System.setOut(printStream);
    }



    public void swaps(Integer m,Integer n){
        Integer temp = m;
        m = n;
        n = temp;



    }


}
